package cate.game.rank.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBRank;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "排行榜奖励领取请求")
@OperationSetter(value = GDOperation.RANK_REWARD, sub = "rankId")
public class RankRewardReq implements MsgInput {
    @NoteField(value = "排行榜id")
    public int rankId;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        EcResult<Void> r = cc.getRole().getFarm().rank.getRankReward(rankId);
        if(r.ok()){
            cc.getRole().getFarm().rank.noticeUpdate();
        }else{
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBRank.REWARD_REQ;
    }
}
